﻿using System;
using System.Collections.Generic;
using System.Threading;

namespace PascalTriangle
{
    public class TriangleContainer
    {   
        public Element[,] table;

        private int level;
        public int Level
        {
            get { return level; }
            set { level = value; }
        }

        public TriangleContainer(int level)
        {
            table = new Element[level, level];
            this.level = level;

            for (int i = 0; i < level; i++)
            {
                for (int j = 0; j < level; j++)
                {
                    table[i, j] = new Element();
                }
            }
        }

        public string LastLine()
        {
            string s = "";
            for (int i = 0; i < level; i++)
            {
                Element e = table[level - 1, i];
                s += "(" + e.Val.ToString() + ";" + e.ThreadID.ToString() + ")";
                e.ReleaseSemaphore();
            }

            return s;
        }
    }
}
